package com.scs.application.modules.outCheck.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.scs.application.core.query.QueryContext;
import com.scs.application.core.query.QueryContextHolder;
import com.scs.application.modules.cfg.utils.ParameterUtils;
import com.scs.application.modules.sys.model.PageResult;
import com.scs.application.modules.sys.model.RestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.scs.application.core.mvc.controller.CrudController;
import com.scs.application.modules.outCheck.service.SpdWoService;
import com.scs.application.modules.outCheck.entity.SpdWo;

import java.util.List;
import java.util.Map;

/**
 */
@RestController
@RequestMapping("/outCheck")
public class SpdWoController extends CrudController<SpdWoService, SpdWo>{
    @Autowired
    SpdWoService spdWoService;
    @PostMapping("/reviewScn")
    public RestResult review(@RequestBody Map<String, Object> para) {
        return service.review(para);
    }

    @GetMapping("/surplusPage")
    public PageResult surplusPage() {
        QueryContext queryContext = QueryContextHolder.currentContext();
        IPage pageResult = service.page(queryContext);
        return PageResult.ok("查询成功", pageResult.getRecords(), pageResult.getTotal());
    }
    @GetMapping("/list")
    public RestResult<List> list() {
        QueryContext queryContext = QueryContextHolder.currentContext();
        String woKey = (String) queryContext.getParams().get("woKey");
        List result = null;
        if (ParameterUtils.isStockcheckUseview()) { //HRP系统
            result = spdWoService.listByWokey(woKey);
        } else {
            result = service.list(queryContext);
        }
        return RestResult.ok("查询成功", result);
    }
}
